package com.childguo.controller;

import com.childguo.pojo.Stu;
import com.childguo.services.StuService;
import com.childguo.webResult.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/stu")
public class StuController {
    @Autowired
    StuService stuService;

    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "HEllo";
    }

    @RequestMapping("/getStuInfo/{sid}")
    @ResponseBody
    public Result<Object> getStu(@PathVariable(name = "sid") Integer id){
        return stuService.selectStuById(id);
    }

    @PostMapping("/insertStuInfo")
    @ResponseBody
    public Result<Object> getStu(@RequestParam("id") Integer id, @RequestParam("sname") String sname){
        Stu stu  = new Stu(id, sname);
        return stuService.InsertStu(stu);
    }
}
